<template>
  <div class="page-box">
    <el-card class="page-box-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        label-width="88px"
        inline
      >
        <el-form-item label="姓名" prop="param.name">
          <el-input
            style="width: 240px"
            v-model="queryParams.param.name"
            placeholder="请输入患者名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="param.idcard">
          <el-input
            style="width: 240px"
            v-model="queryParams.param.idcard"
            placeholder="请输入患者身份证号"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="档案号" prop="param.dnh">
          <el-input
            style="width: 240px"
            v-model="queryParams.param.dnh"
            placeholder="请输入患者档案号"
          ></el-input>
        </el-form-item> -->
        <!-- <el-form-item label="档案状态" prop="param.dnzt">
          <el-select
            style="width: 240px"
            v-model="queryParams.param.dnzt"
            placeholder="请选择档案状态"
          >
            <el-option label="未提交" value="0"> </el-option>
            <el-option label="已提交" value="1"> </el-option>
            <el-option label="已审核" value="2"> </el-option>
            <el-option label="已驳回" value="3"> </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="small"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="small" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['definition:class:add']"
            >新增</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleEdit"
            v-hasPermi="['definition:class:edit']"
            >修改</el-button
          >
        </el-col> -->
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['definition:class:delete']"
            >删除</el-button
          >
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            v-hasPermi="['definition:class:download']"
            @click="downloadData"
            >导出</el-button
          >
        </el-col> -->
      </el-row>
      <el-table
        v-loading="loading"
        :data="dataList"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" fixed />
        <el-table-column
          type="index"
          label="序号"
          width="55"
          align="center"
          fixed
        />
        <el-table-column
          prop="ssks"
          label="所属科室"
          align="center"
          width="100"
        >
        </el-table-column>
        <el-table-column prop="dnh" label="档案号" align="center" width="100">
        </el-table-column>
        <el-table-column
          prop="idcard"
          label="身份证号"
          align="center"
          width="200"
        >
        </el-table-column>
        <el-table-column prop="name" label="姓名" align="center" width="100">
        </el-table-column>
        <el-table-column
          prop="name"
          label="影像报告"
          align="center"
          width="140"
        >
          <template slot-scope="scope">
            <!-- <div>点击查看</div> -->
            <el-link
              v-if="scope.row.url"
              type="primary"
              :underline="false"
              @click="openReportDetails(scope.row)"
              >点击查看</el-link
            >
            <span v-else>暂无报告</span>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="image" label="影像资料" align="center">
          <template slot-scope="scope">
            <el-link
              type="primary"
              :underline="false"
              @click="openDetails(scope.row)"
              >点击查看</el-link
            >
          </template>
        </el-table-column> -->
        <!-- <el-table-column
          prop="source"
          label="数据来源"
          align="center"
          width="200"
        >
        </el-table-column> -->
        <el-table-column
          prop="jdsj"
          label="建档时间"
          align="center"
          width="200"
        >
        </el-table-column>
        <!-- <el-table-column prop="jdr" label="建档人" align="center" width="200">
        </el-table-column>
        <el-table-column prop="shr" label="审核人" align="center" width="200">
        </el-table-column>
        <el-table-column
          prop="shsj"
          label="审核时间"
          align="center"
          width="200"
        >
        </el-table-column> -->
        <el-table-column
          prop="dazt"
          label="档案状态"
          align="center"
          width="200"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.dazt == '0'">未提交</div>
            <div v-else-if="scope.row.dazt == '1'">已提交</div>
            <div v-else-if="scope.row.dazt == '2'">已审核</div>
            <div v-else-if="scope.row.dazt == '3'">已驳回</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="160">
          <template slot-scope="scope">
            <!-- <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleEdit(scope.row)"
              v-hasPermi="['system:dept:edit']"
              >修改</el-button
            > -->
            <el-button
              size="mini"
              type="text"
              style="color: red"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:dept:edit']"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
    <!-- 添加或修改对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="addDialog"
      width="100%"
      append-to-body
    >
      <!-- <dcmview
        :imgurl="imgurl"
        :toolType="toolType"
        width="1150px"
        height="1000px"
      ></dcmview> -->
      <dicDialog v-if="showType == 1" />
      <div v-else-if="showType == 2" style="height: calc(100vh - 180px)">
        {{ reportDetail }}
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { queryData, deleteData } from "@/api/science/portrait";
// import dcmview from "@/components/yuanzhen-dcmView/dcmview.vue";
import dicDialog from "./dicDialog.vue";
export default {
  dicts: ["strategy_type", "strategy_danger_level"],
  components: {
    dicDialog,
  },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      jzlshs: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      selectionData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        param: {
          name: "",
          idcard: "",
          dnh: "",
          dnzt: "",
        },
      },
      tagList: [],
      dataList: [],
      total: 0,
      title: "",
      addDialog: false,
      addForm: {
        type: "",
        riskLevel: "",
        roundList: [],
        round: "",
        content: "",
      },
      rules: {
        text: [{ required: true, message: "请输入变量名称", trigger: "blur" }],
        code: [{ required: true, message: "请输入变量CODE", trigger: "blur" }],
      },
      imgurl:
        "http://124.164.172.125:50020/carbasics2023/h5/dicom/1803679928630251520/2024/6/20/CT.1.2.392.200036.9116.2.5.1.37.2420784501.1718862591.264686.dcm", //传值，传dcm图片地址给<dcmview>组件
      toolType: "RectangleRoi", //工具传值，根据传值绑定不同工具
      showType: 0,
      reportDetail: "档案报告",
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 导出数据
    // downloadData() {
    //   const that = this;
    //   this.$modal
    //     .confirm("是否确认导出当前查询条件下的数据？")
    //     .then(function () {
    //       // 导出
    //       const params = that.queryParams;
    //       return that.download(
    //         exportData,
    //         { ...params.param },
    //         `策略_${new Date().getTime()}.xlsx`
    //       );
    //     })
    //     .then((res) => {
    //       that.$message.success("导出成功");
    //     })
    //     .catch(() => {});
    // },
    // 搜索事件
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置事件
    resetQuery() {
      this.dataList = [];
      this.total = 0;
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 10;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 获取数据列表
    getList() {
      this.loading = true;
      const param = { ...this.queryParams };
      queryData(param).then((response) => {
        this.dataList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 列表选中事件
    handleSelectionChange(selection) {
      this.jzlshs = selection.map((item) => item.jzlsh);
      this.selectionData = [...selection];
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 查看影像资料
    openDetails(data) {
      console.log("data: ", data);
      this.title = "影像资料";
      this.addDialog = true;
      this.showType = 1;
    },
    // 查看档案报告
    openReportDetails(row) {
      window.open(row.url);
      // this.title = "档案报告";
      // this.addDialog = true;
      // this.showType = 2;
    },
    submitForm() {
      this.addDialog = false;
    },
    cancel() {
      this.addDialog = false;
    },
    // 删除策略
    handleDelete(row) {
      const jzlshList = row.jzlsh ? [row.jzlsh] : [...this.jzlshs];
      this.$modal
        .confirm("是否确认删除当前选择的影像数据？")
        .then(() => {
          // 删除
          // this.$message.success("删除成功");
          return deleteData({ jzlshList });
        })
        .then(() => {
          this.$message.success("删除成功");
          this.handleQuery();
        })
        .catch(() => {});
    },
  },
};
</script>
<style lang="scss">
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.row-1 {
  width: 20%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-3 {
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
<style scoped>
/deep/.el-dialog {
  margin-top: 0vh !important;
  height: 100vh !important;
}
/deep/.el-dialog__body {
  height: ;
}
</style>
